<template>
  <view class="page">
    <u-navbar @leftClick="navLeftClick" :fixed="false" title="设置性别" placeholder bgColor="#fff"></u-navbar>
    <view class="content">
      <u-radio-group
        v-model="userInfo.sex"
        placement="column"
        activeColor="#56CB03"
        size="32rpx"
      >
        <view class="list">
          <view class="item">
            <view>男</view>
            <u-radio name="0"></u-radio>
          </view>
          <view class="item">
            <view>女</view>
            <u-radio name="1"></u-radio>
          </view>
          <view class="item" style="border: none;">
            <view>保密</view>
            <u-radio name="2"></u-radio>
          </view>
        </view>
      </u-radio-group>
      <view class="btn" @click="submit">确认提交</view>
    </view>
  </view>
</template>

<script>
import { setUserInfo } from '@/api/index'

export default {
  data() {
    return {
      userInfo: {},
    };
  },
  onLoad() {
    this.userInfo = uni.getStorageSync('userInfo')
  },
  methods: {
    submit() {
      const that = this
      delete this.userInfo.roles
      setUserInfo(this.userInfo).then(res => {
        uni.showToast({
          icon: 'none',
          title: `修改成功`
        })
        setTimeout(() => {
          that.goBack()
        }, 1000)
      })
    }
  },
};
</script>

<style lang="scss" scoped>
.page {
  width: 750rpx;
  min-height: 100vh;
  background-color: #F5F5F5;
  padding-bottom: 80rpx;
  position: relative;
  .content {
    width: 702rpx;
    margin: 0 auto;
    margin-top: 12rpx;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    .list {
      width: 702rpx;
      background: #FFFFFF;
      border-radius: 12rpx;
      margin-bottom: 120rpx;
      padding: 0 22rpx;
      .item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 28rpx 0;
        border-bottom: 2rpx solid #E1E1E1;
        font-size: 28rpx;
      }
    }
    .btn {
      width: 440rpx;
      height: 90rpx;
      line-height: 90rpx;
      text-align: center;
      background: #56CB03;
      border-radius: 200rpx;
      border: 2rpx solid #56CB03;
      font-size: 28rpx;
      color: #FFFFFF;
    }
  }
}
</style>
